package me.zhengjie.modules.anniversary.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.modules.anniversary.service.ImgUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequiredArgsConstructor
@Api(tags = "工具：图片本地上传")
@RequestMapping("/api/imgUpload")
public class ImgUploadController {

    private final ImgUploadService imgUploadService;

    @AnonymousAccess
    @ApiOperation("上传文件")
    @RequestMapping(value ="/upload",method= RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<Object> upload(@RequestParam(value="multipartFile") MultipartFile multipartFile) {
        return new ResponseEntity<>(imgUploadService.upload(multipartFile), HttpStatus.CREATED);
    }
}
